u s i n g   S y s t e m ; 
 
 u s i n g   S y s t e m . D r a w i n g ; 
 
 u s i n g   S y s t e m . C o l l e c t i o n s ; 
 
 u s i n g   S y s t e m . C o m p o n e n t M o d e l ; 
 
 u s i n g   S y s t e m . W i n d o w s . F o r m s ; 
 
 u s i n g   S y s t e m . D a t a ; 
 
 u s i n g   S y s t e m . I O ; 
 
 u s i n g   S y s t e m . T e x t ; 
 
 
 
 n a m e s p a c e   W r o x . P r o f e s s i o n a l C S h a r p . C h a p t e r 0 4 . R e a d B i n a r y F i l e 
 
 { 
 
 	 / / /   < s u m m a r y > 
 
 	 / / /   F o r m 1   n0in0fg0Y00
 
 	 / / /   < / s u m m a r y > 
 
 	 p u b l i c   c l a s s   F o r m 1   :   S y s t e m . W i n d o w s . F o r m s . F o r m 
 
 	 { 
 
 	 	 p r i v a t e   S y s t e m . W i n d o w s . F o r m s . T e x t B o x   t e x t B o x C o n t e n t s ; 
 
 	 	 p r i v a t e   S y s t e m . W i n d o w s . F o r m s . M a i n M e n u   m a i n M e n u 1 ; 
 
 	 	 p r i v a t e   S y s t e m . W i n d o w s . F o r m s . M e n u I t e m   m e n u I t e m 1 ; 
 
 	 	 p r i v a t e   S y s t e m . W i n d o w s . F o r m s . M e n u I t e m   m e n u F i l e O p e n ; 
 
 	 	 / / /   < s u m m a r y > 
 
 	 	 / / /   _j00000	Ypeg0Y00
 
 	 	 / / /   < / s u m m a r y > 
 
 	 	 p r i v a t e   S y s t e m . C o m p o n e n t M o d e l . C o n t a i n e r   c o m p o n e n t s   =   n u l l ; 
 
 	 	 O p e n F i l e D i a l o g   C h o o s e O p e n F i l e D i a l o g   =   n e w   O p e n F i l e D i a l o g ( ) ; 
 
 	 	 s t r i n g   C h o s e n F i l e ; 
 
 
 
 	 	 p u b l i c   F o r m 1 ( ) 
 
 	 	 { 
 
 	 	 	 I n i t i a l i z e C o m p o n e n t ( ) ; 
 
 	 	 	 m e n u F i l e O p e n . C l i c k   + =   n e w   E v e n t H a n d l e r ( O n F i l e O p e n ) ; 
 
 	 	 	 C h o o s e O p e n F i l e D i a l o g . F i l e O k   + =   n e w   C a n c e l E v e n t H a n d l e r ( O n O p e n F i l e D i a l o g O K ) ; 
 
 	 	 } 
 
 
 
 	 	 / / /   < s u m m a r y > 
 
 	 	 / / /   O(uU00f0D000000k0_Qt0[LW0~0Y00
 
 	 	 / / /   < / s u m m a r y > 
 
 	 	 p r o t e c t e d   o v e r r i d e   v o i d   D i s p o s e (   b o o l   d i s p o s i n g   ) 
 
 	 	 { 
 
 	 	 	 i f (   d i s p o s i n g   ) 
 
 	 	 	 { 
 
 	 	 	 	 i f   ( c o m p o n e n t s   ! =   n u l l )   
 
 	 	 	 	 { 
 
 	 	 	 	 	 c o m p o n e n t s . D i s p o s e ( ) ; 
 
 	 	 	 	 } 
 
 	 	 	 } 
 
 	 	 	 b a s e . D i s p o s e (   d i s p o s i n g   ) ; 
 
 	 	 } 
 
 
 
 	 	 # r e g i o n   W i n d o w s   F o r m   D e s i g n e r   g e n e r a t e d   c o d e 
 
 	 	 / / /   < s u m m a r y > 
 
 	 	 / / /   0000  0000k0_j00000g0Y00S0n00000n0Q[0
 
 	 	 / / /   000  0000g0	YfW0j0D0g0O0`0U0D00
 
 	 	 / / /   < / s u m m a r y > 
 
 	 	 p r i v a t e   v o i d   I n i t i a l i z e C o m p o n e n t ( ) 
 
 	 	 { 
 
 	 	 	 t h i s . m e n u I t e m 1   =   n e w   S y s t e m . W i n d o w s . F o r m s . M e n u I t e m ( ) ; 
 
 	 	 	 t h i s . m e n u F i l e O p e n   =   n e w   S y s t e m . W i n d o w s . F o r m s . M e n u I t e m ( ) ; 
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s   =   n e w   S y s t e m . W i n d o w s . F o r m s . T e x t B o x ( ) ; 
 
 	 	 	 t h i s . m a i n M e n u 1   =   n e w   S y s t e m . W i n d o w s . F o r m s . M a i n M e n u ( ) ; 
 
 	 	 	 t h i s . S u s p e n d L a y o u t ( ) ; 
 
 	 	 	 / /   
 
 	 	 	 / /   m e n u I t e m 1 
 
 	 	 	 / /   
 
 	 	 	 t h i s . m e n u I t e m 1 . I n d e x   =   0 ; 
 
 	 	 	 t h i s . m e n u I t e m 1 . M e n u I t e m s . A d d R a n g e ( n e w   S y s t e m . W i n d o w s . F o r m s . M e n u I t e m [ ]   { 
 
 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	     t h i s . m e n u F i l e O p e n } ) ; 
 
 	 	 	 t h i s . m e n u I t e m 1 . T e x t   =   " 0000" ; 
 
 	 	 	 / /   
 
 	 	 	 / /   m e n u F i l e O p e n 
 
 	 	 	 / /   
 
 	 	 	 t h i s . m e n u F i l e O p e n . I n d e x   =   0 ; 
 
 	 	 	 t h i s . m e n u F i l e O p e n . T e x t   =   " O0" ; 
 
 	 	 	 / /   
 
 	 	 	 / /   t e x t B o x C o n t e n t s 
 
 	 	 	 / /   
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s . B a c k C o l o r   =   S y s t e m . D r a w i n g . C o l o r . W h i t e ; 
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s . F o n t   =   n e w   S y s t e m . D r a w i n g . F o n t ( " C o u r i e r   N e w " ,   9 . 7 5 F ,   S y s t e m . D r a w i n g . F o n t S t y l e . R e g u l a r ,   S y s t e m . D r a w i n g . G r a p h i c s U n i t . P o i n t ,   ( ( S y s t e m . B y t e ) ( 0 ) ) ) ; 
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s . L o c a t i o n   =   n e w   S y s t e m . D r a w i n g . P o i n t ( 8 ,   8 ) ; 
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s . M u l t i l i n e   =   t r u e ; 
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s . N a m e   =   " t e x t B o x C o n t e n t s " ; 
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s . R e a d O n l y   =   t r u e ; 
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s . S c r o l l B a r s   =   S y s t e m . W i n d o w s . F o r m s . S c r o l l B a r s . B o t h ; 
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s . S i z e   =   n e w   S y s t e m . D r a w i n g . S i z e ( 5 5 2 ,   2 4 8 ) ; 
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s . T a b I n d e x   =   0 ; 
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s . T e x t   =   " " ; 
 
 	 	 	 / /   
 
 	 	 	 / /   m a i n M e n u 1 
 
 	 	 	 / /   
 
 	 	 	 t h i s . m a i n M e n u 1 . M e n u I t e m s . A d d R a n g e ( n e w   S y s t e m . W i n d o w s . F o r m s . M e n u I t e m [ ]   { 
 
 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	     t h i s . m e n u I t e m 1 } ) ; 
 
 	 	 	 / /   
 
 	 	 	 / /   F o r m 1 
 
 	 	 	 / /   
 
 	 	 	 t h i s . A u t o S c a l e B a s e S i z e   =   n e w   S y s t e m . D r a w i n g . S i z e ( 5 ,   1 2 ) ; 
 
 	 	 	 t h i s . C l i e n t S i z e   =   n e w   S y s t e m . D r a w i n g . S i z e ( 5 6 8 ,   2 6 9 ) ; 
 
 	 	 	 t h i s . C o n t r o l s . A d d R a n g e ( n e w   S y s t e m . W i n d o w s . F o r m s . C o n t r o l [ ]   { 
 
 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	     t h i s . t e x t B o x C o n t e n t s } ) ; 
 
 	 	 	 t h i s . M e n u   =   t h i s . m a i n M e n u 1 ; 
 
 	 	 	 t h i s . N a m e   =   " F o r m 1 " ; 
 
 	 	 	 t h i s . T e x t   =   " R e a d B i n a r y F i l e " ; 
 
 	 	 	 t h i s . R e s u m e L a y o u t ( f a l s e ) ; 
 
 
 
 	 	 } 
 
 	 	 # e n d r e g i o n 
 
 
 
 	 	 v o i d   O n F i l e O p e n ( o b j e c t   S e n d e r ,   E v e n t A r g s   e ) 
 
 	 	 { 
 
 	 	 	 C h o o s e O p e n F i l e D i a l o g . S h o w D i a l o g ( ) ; 
 
 	 	 } 
 
 
 
 	 	 v o i d   O n O p e n F i l e D i a l o g O K ( o b j e c t   S e n d e r ,   C a n c e l E v e n t A r g s   e ) 
 
 	 	 { 
 
 	 	 	 C h o s e n F i l e   =   C h o o s e O p e n F i l e D i a l o g . F i l e N a m e ; 
 
 	 	 	 t h i s . T e x t   =   C h o s e n F i l e ; 
 
 	 	 	 D i s p l a y F i l e ( ) ; 
 
 	 	 } 
 
 
 
 	 	 v o i d   D i s p l a y F i l e ( ) 
 
 	 	 { 
 
 	 	 	 i n t   n C o l s   =   1 6 ; 
 
 	 	 	 F i l e S t r e a m   I n S t r e a m   =   n e w   F i l e S t r e a m ( C h o s e n F i l e ,   F i l e M o d e . O p e n ,   F i l e A c c e s s . R e a d ) ; 
 
 	 	 	 l o n g   n B y t e s T o R e a d   =   I n S t r e a m . L e n g t h ; 
 
 	 	 	 i f   ( n B y t e s T o R e a d   >   6 5 5 3 6 )   
 
 	 	 	 	 n B y t e s T o R e a d   =   6 5 5 3 6 ; 
 
 	 	 	 i n t   n L i n e s   =   ( i n t ) ( n B y t e s T o R e a d / n C o l s )   +   1 ; 
 
 	 	 	 s t r i n g   [ ]   L i n e s   =   n e w   s t r i n g [ n L i n e s ] ; 
 
 	 	 	 i n t   n B y t e s R e a d   =   0 ; 
 
 	 	 	 f o r   ( i n t   i = 0   ;   i < n L i n e s   ;   i + + ) 
 
 	 	 	 { 
 
 	 	 	 	 S t r i n g B u i l d e r   N e x t L i n e   =   n e w   S t r i n g B u i l d e r ( ) ; 
 
 	 	 	 	 N e x t L i n e . C a p a c i t y   =   4 * n C o l s ; 
 
 	 	 	 	 f o r   ( i n t   j   =   0   ;   j < n C o l s   ;   j + + ) 
 
 	 	 	 	 { 
 
 	 	 	 	 	 i n t   N e x t B y t e   =   I n S t r e a m . R e a d B y t e ( ) ; 
 
 	 	 	 	 	 n B y t e s R e a d + + ; 
 
 	 	 	 	 	 i f   ( N e x t B y t e   <   0   | |   n B y t e s R e a d   >   6 5 5 3 6 ) 
 
 	 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 	 c h a r   N e x t C h a r   =   ( c h a r ) N e x t B y t e ; 
 
 
 
 	 	 	 	 	 i f   ( N e x t C h a r   <   1 6 ) 
 
 	 	 	 	 	 	 N e x t L i n e . A p p e n d ( "   x 0 "   +   s t r i n g . F o r m a t ( " { 0 , 1 : X } " ,   ( i n t ) N e x t C h a r ) ) ; 
 
 	 	 	 	 	 e l s e   i f   
 
 	 	 	 	 	 	 ( c h a r . I s L e t t e r O r D i g i t ( N e x t C h a r )   | |   c h a r . I s P u n c t u a t i o n ( N e x t C h a r ) ) 
 
 	 	 	 	 	 	 N e x t L i n e . A p p e n d ( "     "   +   N e x t C h a r   +   "   " ) ; 
 
 	 	 	 	 	 e l s e 
 
 	 	 	 	 	 	 N e x t L i n e . A p p e n d ( "   x "   +   s t r i n g . F o r m a t ( " { 0 , 2 : X } " ,   ( i n t ) N e x t C h a r ) ) ; 
 
 	 	 	 	 } 
 
 	 	 	 	 L i n e s [ i ]   =   N e x t L i n e . T o S t r i n g ( ) ; 
 
 	 	 	 } 
 
 	 	 	 I n S t r e a m . C l o s e ( ) ; 
 
 	 	 	 t h i s . t e x t B o x C o n t e n t s . L i n e s   =   L i n e s ; 
 
 	 	 } 
 
 
 
 	 	 / / /   < s u m m a r y > 
 
 	 	 / / /   00000000n0000  0000  0000g0Y00
 
 	 	 / / /   < / s u m m a r y > 
 
 	 	 [ S T A T h r e a d ] 
 
 	 	 s t a t i c   v o i d   M a i n ( )   
 
 	 	 { 
 
 	 	 	 A p p l i c a t i o n . R u n ( n e w   F o r m 1 ( ) ) ; 
 
 	 	 } 
 
 	 } 
 
 } 
 
 